import asyncio
import logging
import site
import sys
from pathlib import Path

print(site.getsitepackages())

logging.basicConfig(
	level=logging.INFO,
	format="%(asctime)s - %(threadName)s_%(thread)d - %(name)s - %(levelname)s - %(message)s",
	stream=sys.stdout,
)

logger = logging.getLogger(__name__)

logger.info("demo")


# r = httpx.get("http://127.0.0.1:8000/docs")
# print(r.headers, r.content)


# json_str = """{"code":200,"msg":"操作成功","data":{"userInfo":{"id":"8b8f034690244c2ab3d94fa4e54a7906","employNo":"RC-35855","account":"18902155179","realName":"李宇航","headIcon":"https://rock-system.obs.cn-southwest-2.myhuaweicloud.com:443/head%2Fhead20220311_f27cc0ac8df0448e99099caa2924590f.jpg","organizeId":"cb228c8edb8a402087bff5995beceb4f","organizeName":"天津融和互联高新技术股份有限公司","departmentId":"b24e6f51a1e74ecab333f5cefb5a5a5d","departmentName":"研发中心","roleId":"1d59f0e85c8e411b8e83e75075778035,f4bf8eed055a4a379663f1b2f3612f44,d1e447a8fa3048b29d881fb2cd7541b9,afc268a3342f48eda82be76eecf825c3,e4371afd2dd544ccbdd288f9697fd20e,3aec0ad1f944461592dcab2419e14c5f,7e26ef66448f40b18132eb62d2932b52,73ec874923c1467f9b6cb4fb5808b4fe,64d18a15826d464eb3b583c8c15c6093,f1de093af2ca42f1bbd02c57d6dce5b2,3557fe4d43b5464580a64eb669b29b1d,cbdddec7c9fd4ae5ac10bf0b18488fcd","roleName":"小程序用户,工作日志,默认角色,遨游商旅,线下会议,线上会议,会议室使用者,项目管理PC,项目看板,禅道日志","positionId":"e458768d61454d7baba4fb1a37dc3a03","positionName":"后端工程师","gender":1,"birthday":689097600000,"mobilePhone":18902155179,"email":null,"nation":"汉族","inside":1,"tenantCode":"rockcheck","path":"b24e6f51a1e74ecab333f5cefb5a5a5d,cb228c8edb8a402087bff5995beceb4f,94172bdacf284f9a8e978e5ddf07c58d,f15ed199a65e4b3eb36716be11f30a2f,cf6cf8d7735c4cd8ba7476d93a8b1278,-1"},"theme":"classic","isNew":false,"token":"bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MDA0ODkyNTMsInVzZXJfbmFtZSI6IjE4OTAyMTU1MTc5IiwianRpIjoiZjA3YzRlMGItZjkwYi00OGMxLTlkNjktY2Y3NWY3ZjVlMDVkIiwiY2xpZW50X2lkIjoiYWRtaW4iLCJzY29wZSI6WyJhbGwiXSwidG9rZW4iOiJyb2NrY2hlY2tsb2dpbl90b2tlbl9iMDIzYjQ5Nzk5NjA0NGNkYWExYWE1NDFmYmE1MDA4ZiJ9.9PdRjbo8JhM5C2GFL7pc8x9ENMgCCXLIa_4x-1WrQeM"}}"""

# res = LoginResponse.model_validate_json(json_str, strict=False)
# print(res)
# json_str = """{"code":100, "msg":"sss"}"""

# aa = SliderCodeResponse.model_validate_json(json_str, strict=False)
# print(aa)


root_path = Path(__file__).parent
env_path = root_path.joinpath(root_path, ".env")

print(env_path.exists())


async def say_after(delay: float, what: str):
	await asyncio.sleep(delay)
	logger.info("what = %s", what)
	return f"{what}-{delay}"


async def main1():
	# await say_after(1, "hello")
	# await say_after(2, "word")
	logger.info("start")
	task1 = asyncio.create_task(say_after(1, "hello"))
	task2 = asyncio.create_task(say_after(2, "hello"))
	res1 = await task1
	res2 = await task2
	logger.info(f"{res1}, {res2}, end")


async def main():
	logger.info("start")
	res = await asyncio.gather(say_after(1, "hello"), say_after(2, "hello"))
	logger.info(f"{res}, end")


asyncio.run(main())
